Skip to content

Homogenize $ and run notation #6689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2019

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Jun 15, 2019

Now both $ and run correspond to

def $[T](expr: Expr[T]): T = ...
def run[T](expr: Expr[T]): T = ...

This is the first step towards correct context handling in quote and splices.

Next step will be to use a quote QuoteContext => Expr[T] (see #6688)

@nicolasstucki nicolasstucki mentioned this pull request Jun 15, 2019
16 tasks
@nicolasstucki nicolasstucki requested a review from liufengyun June 15, 2019 10:59
Now both `$` and `run` correspond to
```scala
def $[T](expr: Expr[T]): T = ...
def run[T](expr: Expr[T]): T = ...
```

This is the first step towards correct context handling in quote and splices.
@nicolasstucki nicolasstucki force-pushed the homogenize-run-and-splice branch from 74f30df to 9e3fdb9 Compare June 15, 2019 11:05
@nicolasstucki nicolasstucki marked this pull request as ready for review June 15, 2019 15:16
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

One minor question: are we going to support Expr[T].run through extension methods in the lib? From the programmers' perspective, it seems to be more friendly.

@nicolasstucki nicolasstucki force-pushed the homogenize-run-and-splice branch from e4b8544 to 9e3fdb9 Compare June 17, 2019 13:43
@nicolasstucki
Copy link
Contributor Author

We won't support Expr[T].run as an extension method because it should be an extension method (QuoteContext => Expr[T]).run which is currently not possible.

@nicolasstucki nicolasstucki merged commit c28f8b3 into scala:master Jun 17, 2019
@nicolasstucki nicolasstucki deleted the homogenize-run-and-splice branch June 17, 2019 14:18
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Jun 17, 2019

We should also never call .run on an expression that came from within a run{...} or a ${...} because of scope extrusion. Having only run{...} as a top level entry point will help us avoid users from calling run in the wrong place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants